package com.action;

import java.io.Serializable;
import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.entity.Department;
import com.entity.Pagination;
import com.entity.Person;
import com.opensymphony.xwork2.ActionSupport;
import com.service.DepartmentService;
import com.service.PersonService;
//@ParentPackage("json-default")  
//@Result(type="json",name="dep") 
public class DepAction extends BaseAction implements Serializable {

	@Autowired
	private DepartmentService departmentService;
	List<Department> departments;
	private Department department;
	private Pagination page;
	private int pageNum = 1;// dwz分页使用
	private int numPerPage = 20;
	public Department getDepartment() {
		return department;
	}


	public void setDepartment(Department department) {
		this.department = department;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public List<Department> getDepartments() {
		return departments;
	}


	public void setDepartments(List<Department> departments) {
		this.departments = departments;
	}

	//@Action(results={@Result(type="json",name="success")})
	@Action(results={@Result(name="success", location="lookupdep.jsp") })
	@Override
	public String execute() throws Exception {		
		page = new Pagination(pageNum,numPerPage);		
		departments = departmentService.getAllDepartments(page,department);
		return "success";
	}


	public int getPageNum() {
		return pageNum;
	}


	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}


	public int getNumPerPage() {
		return numPerPage;
	}


	public void setNumPerPage(int numPerPage) {
		this.numPerPage = numPerPage;
	}


	public Pagination getPage() {
		return page;
	}


	public void setPage(Pagination page) {
		this.page = page;
	}

}
